package com.example.chapter4;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class TestActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		
		TabHost tabHost = (TabHost) this.findViewById(android.R.id.tabhost);
		tabHost.setup();
		
		Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
		
		for (int i = 1; i <= 3; i++) {
			int id = 0;
			
			if (i == 1) {
				id = R.id.tab1;
			} else if (i == 2) {
				id = R.id.tab2;
			} else if (i == 3) {
				id = R.id.tab3;
			}
			TabSpec tabSpec = tabHost.newTabSpec("tab" + i).setIndicator("tab" + i, drawable).setContent(id);
			tabHost.addTab(tabSpec);
		}
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
}
